/**
 *@描述：知识申请授权列表
 *@作者：殷健
 *@创建时间：2022/7/15
 *@最后修改时间：2022/7/15
 */

import ProTable, { ProColumns } from '@ant-design/pro-table';
import styles from "@/pages/Dashboard/Home/index.less";
import {uniqueId} from "lodash";
import moment from "moment";
import { Tag } from 'antd';

enum ApplyStatus{
    "待审批"="0",
    "已通过"="1",
    "已拒绝"="2",
}

enum ApplyStatusColors{
    "blue" = ApplyStatus.待审批,
    "green" = ApplyStatus.已通过,
    "red" = ApplyStatus.已拒绝,
}

const ApplyList = (
    {
        data,
    }:{
        data:AircasKB.KnowledgeApply.AuthorizationApplyListResponse[];//接收传进来的数据结构
    }
) => {
    const columns: ProColumns<AircasKB.KnowledgeApply.AuthorizationApplyListResponse>[] = [
        {
            dataIndex: 'knowledgeTitle',
            title: '知识标题',
            ellipsis: true,
            width:120,
        },
        {
            dataIndex: 'userName',
            title: '申请人',
            ellipsis: true,
            align: 'center',
            width:80,
        },
        {
            dataIndex: 'applyDate',
            title: '最后修改时间',
            sorter: true,
            align: 'center',
            width:120,
            render: (_: any) => moment(_).format('YYYY-MM-DD'),
        },
        {
            dataIndex: 'statusName',
            title: '状态',
            sorter: true,
            width: 80,
            align: 'center',
            render: (_, record) => {
                // @ts-ignore
                return <Tag color={ApplyStatusColors[record.status]}>{record.statusName}</Tag>
            },
        },
    ];
    return (
        <ProTable<AircasKB.KnowledgeApply.AuthorizationApplyListResponse>
            className={styles.simpleTable}
            bordered
            search={false}
            options={false}
            rowKey={() => uniqueId()}
            columns={columns}
            pagination={false}
            dataSource={data ?? []}
        ></ProTable>
    )
}

export default ApplyList;
